﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BridgeModel
{
    /// <summary>
    /// 桥接模式参与者Abstraction
    /// </summary>
    public abstract class Shape
    {
        private DrawingProgramming _dp;

        public Shape()
        {
        }

        public Shape(DrawingProgramming dp)
        {
            this.Dp = dp;
        }
        /// <summary>
        /// 画图
        /// </summary>
        public abstract void Draw();

        public DrawingProgramming Dp
        {
            get { return _dp; }
            set { _dp = value; }
        }
    }
    /// <summary>
    /// 三角形
    /// </summary>
    public class Triangle : Shape
    {
        private int _rows = 0;

        public Triangle(DrawingProgramming dp, int rows)
            : base(dp)
        {
            this.Rows = rows;
        }

        public override void Draw()
        {
            this.DrawTriangle(this.Rows);
        }

        public void DrawTriangle(int rows)
        {
            this.Dp.DrawTriangle(rows);
        }

        public int Rows
        {
            get { return _rows; }
            set { _rows = value; }
        }
    }
    /// <summary>
    /// 长方形
    /// </summary>
    public class Retangle : Shape
    {
        private int _width = 0;
        private int _height = 0;

        public Retangle(DrawingProgramming dp, int width, int height)
            : base(dp)
        {
            this.Width = width;
            this.Height = height;
        }

        public override void Draw()
        {
            this.DrawRetangle(Width, Height);
        }

        public void DrawRetangle(int width, int height)
        {
            this.Dp.DrawRetangle(width, height);
        }

        public int Width
        {
            get { return _width; }
            set { _width = value; }
        }

        public int Height
        {
            get { return _height; }
            set { _height = value; }
        }
    }
}
